package com.example.customviewpage;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private TextView tv;
    private LinearLayout ll;

    int[] ins = new int[]{R.mipmap.a,R.mipmap.b,R.mipmap.c,R.mipmap.d,R.mipmap.e};
    private int currentPosition;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        viewPager = findViewById(R.id.viewpage);
        tv = findViewById(R.id.tv);
        ll = findViewById(R.id.ll);
        //限定预加载页面的个数
        viewPager.setOffscreenPageLimit(3);
        viewPager.setAdapter(new MyAdapter(this,ins,viewPager));
        viewPager.setCurrentItem(1,false);



    }
}
